package com.aaa.vip.controller;

import com.aaa.common.entity.UserBalanceLog;
import com.aaa.common.util.BaseUtil;
import com.aaa.common.util.Result;
import com.aaa.common.vo.Page;
import com.aaa.vip.service.UserBalanceLogService;
import lombok.extern.log4j.Log4j2;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 余额详细(UserBalanceLog)表控制层
 *
 * @author makejava
 * @since 2025-09-25 19:09:13
 */
@RestController
@RequestMapping("userBalanceLog")
@Log4j2
public class UserBalanceLogController {
    /**
     * 服务对象
     */
    @Resource
    private UserBalanceLogService userBalanceLogService;
    /**
     * 通过用户token查询充值详细
     * @return
     */
    @GetMapping("selectByUserIdTopUp")
    public Result selectByUserIdTopUp() {
        return BaseUtil.success(this.userBalanceLogService.selectByUserIdTopUp());
    }
    /**
     * 通过用户token查询支出详细
     * @return
     */
    @GetMapping("selectByUserIdPayment")
    public Result selectByUserIdPayment() {
        return BaseUtil.success(this.userBalanceLogService.selectByUserIdPayment());
    }

    /**
     * 通过用户token查询余额详细
     * @return
     */
    @GetMapping("selectByUserId")
    public Result selectByUserId() {
        return BaseUtil.success(this.userBalanceLogService.selectByUserId());
    }
    /**
     * 分页查询
     *
     * @param page 分页对象
     * @return 查询结果
     */
    @PostMapping("queryByPage")
    public Result queryByPage(@RequestBody Page<UserBalanceLog> page) {
        return BaseUtil.success(this.userBalanceLogService.queryByPage(page));
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("queryById")
    public Result queryById(Integer id) {
        return BaseUtil.success(this.userBalanceLogService.queryById(id));
    }

    /**
     * 新增数据
     *
     * @param userBalanceLog 实体
     * @return 新增结果
     */
    @PostMapping("add")
    public Result add(@RequestBody UserBalanceLog userBalanceLog) {
        return BaseUtil.success(this.userBalanceLogService.insert(userBalanceLog));
    }

    /**
     * 编辑数据
     *
     * @param userBalanceLog 实体
     * @return 编辑结果
     */
    @PostMapping("edit")
    public Result edit(@RequestBody UserBalanceLog userBalanceLog) {
        return BaseUtil.success(this.userBalanceLogService.update(userBalanceLog));
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @DeleteMapping("deleteById")
    public Result deleteById(Integer id) {
        return BaseUtil.success(this.userBalanceLogService.deleteById(id));
    }

}

